/*
 * Copyright (c) ShaoxiongDu <Shaoxiong.dev@aliyun.com> 2021 all Rights Reserved
 */

package zh.codegym.task.task08.task0809;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/* 
10000 次插入所需的时间
*/

public class Solution {
    public static void main(String[] args) {
        System.out.println(getInsertTimeInMs(new ArrayList()));
        System.out.println(getInsertTimeInMs(new LinkedList()));
    }

    public static long getInsertTimeInMs(List list) {
        // 在此编写你的代码
        Date stateDate = new Date();
        insert10000(list);
        Date endDate = new Date();
        // 在此编写你的代码
        return endDate.getTime() - stateDate.getTime();
    }

    public static void insert10000(List list) {
        for (int i = 0; i < 10000; i++) {
            list.add(0, new Object());
        }
    }
}
